package com.zhitong.ztblog.mappers;

import com.zhitong.ztblog.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Select("select * from user where username=#{username}")
    public User findByUsername(String username);

    @Select("select * from user where id=#{id}")
    public User findById(int id);

    @Insert("insert into user values (null,#{userName},#{password},#{nickName},#{phone},#{address},#{email},#{createTime},#{iconUrl})")
    public void insertUser(User user);

    @Select("select nickname from user where id =#{id}")
    public String findNickName(int id);

    @Update("update user set nickName=#{nickName},phone=#{phone},email=#{email},address=#{address},iconUrl=#{iconUrl}")
    public void updateUser(User user);
}
